// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Enrich
{
	public sealed class EnrichPutPolicyRequestParameters : RequestParameters<EnrichPutPolicyRequestParameters>
	{
	}

	public sealed partial class EnrichPutPolicyRequest : PlainRequestBase<EnrichPutPolicyRequestParameters>
	{
		public EnrichPutPolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("geo_match")]
		public Elastic.Clients.Elasticsearch.Enrich.Policy? GeoMatch { get; set; }

		[JsonInclude]
		[JsonPropertyName("match")]
		public Elastic.Clients.Elasticsearch.Enrich.Policy? Match { get; set; }

		[JsonInclude]
		[JsonPropertyName("range")]
		public Elastic.Clients.Elasticsearch.Enrich.Policy? Range { get; set; }
	}

	public sealed partial class EnrichPutPolicyRequestDescriptor<TDocument> : RequestDescriptorBase<EnrichPutPolicyRequestDescriptor<TDocument>, EnrichPutPolicyRequestParameters>
	{
		internal EnrichPutPolicyRequestDescriptor(Action<EnrichPutPolicyRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public EnrichPutPolicyRequestDescriptor(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
		{
		}

		internal EnrichPutPolicyRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public EnrichPutPolicyRequestDescriptor<TDocument> Name(Elastic.Clients.Elasticsearch.Name name)
		{
			RouteValues.Required("name", name);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Enrich.Policy? GeoMatchValue { get; set; }

		private PolicyDescriptor<TDocument> GeoMatchDescriptor { get; set; }

		private Action<PolicyDescriptor<TDocument>> GeoMatchDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Enrich.Policy? MatchValue { get; set; }

		private PolicyDescriptor<TDocument> MatchDescriptor { get; set; }

		private Action<PolicyDescriptor<TDocument>> MatchDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Enrich.Policy? RangeValue { get; set; }

		private PolicyDescriptor<TDocument> RangeDescriptor { get; set; }

		private Action<PolicyDescriptor<TDocument>> RangeDescriptorAction { get; set; }

		public EnrichPutPolicyRequestDescriptor<TDocument> GeoMatch(Elastic.Clients.Elasticsearch.Enrich.Policy? geoMatch)
		{
			GeoMatchDescriptor = null;
			GeoMatchDescriptorAction = null;
			GeoMatchValue = geoMatch;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> GeoMatch(PolicyDescriptor<TDocument> descriptor)
		{
			GeoMatchValue = null;
			GeoMatchDescriptorAction = null;
			GeoMatchDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> GeoMatch(Action<PolicyDescriptor<TDocument>> configure)
		{
			GeoMatchValue = null;
			GeoMatchDescriptor = null;
			GeoMatchDescriptorAction = configure;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Match(Elastic.Clients.Elasticsearch.Enrich.Policy? match)
		{
			MatchDescriptor = null;
			MatchDescriptorAction = null;
			MatchValue = match;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Match(PolicyDescriptor<TDocument> descriptor)
		{
			MatchValue = null;
			MatchDescriptorAction = null;
			MatchDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Match(Action<PolicyDescriptor<TDocument>> configure)
		{
			MatchValue = null;
			MatchDescriptor = null;
			MatchDescriptorAction = configure;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Range(Elastic.Clients.Elasticsearch.Enrich.Policy? range)
		{
			RangeDescriptor = null;
			RangeDescriptorAction = null;
			RangeValue = range;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Range(PolicyDescriptor<TDocument> descriptor)
		{
			RangeValue = null;
			RangeDescriptorAction = null;
			RangeDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor<TDocument> Range(Action<PolicyDescriptor<TDocument>> configure)
		{
			RangeValue = null;
			RangeDescriptor = null;
			RangeDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (GeoMatchDescriptor is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, GeoMatchDescriptor, options);
			}
			else if (GeoMatchDescriptorAction is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, new PolicyDescriptor<TDocument>(GeoMatchDescriptorAction), options);
			}
			else if (GeoMatchValue is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, GeoMatchValue, options);
			}

			if (MatchDescriptor is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, MatchDescriptor, options);
			}
			else if (MatchDescriptorAction is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, new PolicyDescriptor<TDocument>(MatchDescriptorAction), options);
			}
			else if (MatchValue is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, MatchValue, options);
			}

			if (RangeDescriptor is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, RangeDescriptor, options);
			}
			else if (RangeDescriptorAction is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, new PolicyDescriptor<TDocument>(RangeDescriptorAction), options);
			}
			else if (RangeValue is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, RangeValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class EnrichPutPolicyRequestDescriptor : RequestDescriptorBase<EnrichPutPolicyRequestDescriptor, EnrichPutPolicyRequestParameters>
	{
		internal EnrichPutPolicyRequestDescriptor(Action<EnrichPutPolicyRequestDescriptor> configure) => configure.Invoke(this);
		public EnrichPutPolicyRequestDescriptor(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
		{
		}

		internal EnrichPutPolicyRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.EnrichPutPolicy;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public EnrichPutPolicyRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name name)
		{
			RouteValues.Required("name", name);
			return Self;
		}

		private Elastic.Clients.Elasticsearch.Enrich.Policy? GeoMatchValue { get; set; }

		private PolicyDescriptor GeoMatchDescriptor { get; set; }

		private Action<PolicyDescriptor> GeoMatchDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Enrich.Policy? MatchValue { get; set; }

		private PolicyDescriptor MatchDescriptor { get; set; }

		private Action<PolicyDescriptor> MatchDescriptorAction { get; set; }

		private Elastic.Clients.Elasticsearch.Enrich.Policy? RangeValue { get; set; }

		private PolicyDescriptor RangeDescriptor { get; set; }

		private Action<PolicyDescriptor> RangeDescriptorAction { get; set; }

		public EnrichPutPolicyRequestDescriptor GeoMatch(Elastic.Clients.Elasticsearch.Enrich.Policy? geoMatch)
		{
			GeoMatchDescriptor = null;
			GeoMatchDescriptorAction = null;
			GeoMatchValue = geoMatch;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor GeoMatch(PolicyDescriptor descriptor)
		{
			GeoMatchValue = null;
			GeoMatchDescriptorAction = null;
			GeoMatchDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor GeoMatch(Action<PolicyDescriptor> configure)
		{
			GeoMatchValue = null;
			GeoMatchDescriptor = null;
			GeoMatchDescriptorAction = configure;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Match(Elastic.Clients.Elasticsearch.Enrich.Policy? match)
		{
			MatchDescriptor = null;
			MatchDescriptorAction = null;
			MatchValue = match;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Match(PolicyDescriptor descriptor)
		{
			MatchValue = null;
			MatchDescriptorAction = null;
			MatchDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Match(Action<PolicyDescriptor> configure)
		{
			MatchValue = null;
			MatchDescriptor = null;
			MatchDescriptorAction = configure;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Range(Elastic.Clients.Elasticsearch.Enrich.Policy? range)
		{
			RangeDescriptor = null;
			RangeDescriptorAction = null;
			RangeValue = range;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Range(PolicyDescriptor descriptor)
		{
			RangeValue = null;
			RangeDescriptorAction = null;
			RangeDescriptor = descriptor;
			return Self;
		}

		public EnrichPutPolicyRequestDescriptor Range(Action<PolicyDescriptor> configure)
		{
			RangeValue = null;
			RangeDescriptor = null;
			RangeDescriptorAction = configure;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (GeoMatchDescriptor is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, GeoMatchDescriptor, options);
			}
			else if (GeoMatchDescriptorAction is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, new PolicyDescriptor(GeoMatchDescriptorAction), options);
			}
			else if (GeoMatchValue is not null)
			{
				writer.WritePropertyName("geo_match");
				JsonSerializer.Serialize(writer, GeoMatchValue, options);
			}

			if (MatchDescriptor is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, MatchDescriptor, options);
			}
			else if (MatchDescriptorAction is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, new PolicyDescriptor(MatchDescriptorAction), options);
			}
			else if (MatchValue is not null)
			{
				writer.WritePropertyName("match");
				JsonSerializer.Serialize(writer, MatchValue, options);
			}

			if (RangeDescriptor is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, RangeDescriptor, options);
			}
			else if (RangeDescriptorAction is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, new PolicyDescriptor(RangeDescriptorAction), options);
			}
			else if (RangeValue is not null)
			{
				writer.WritePropertyName("range");
				JsonSerializer.Serialize(writer, RangeValue, options);
			}

			writer.WriteEndObject();
		}
	}
}